package com.resou.reader.mine.vipcenter.payview.nosecretpay;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.resou.reader.R;
import com.resou.reader.base.ResouBaseActivity;
import com.resou.reader.utils.ToastUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 免密支付授权页面
 */
public class NoSecretPayActivity extends ResouBaseActivity<NoSecretPayPresenter> implements INoSecretPayContract.INoSecretPayView {
    @BindView(R.id.tvMoney)
    TextView tvMoney;
    @BindView(R.id.cbAgree)
    CheckBox cbAgree;
    @BindView(R.id.tvPay)
    TextView tvPay;

    public static void start(Context context) {
        Intent starter = new Intent(context, NoSecretPayActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected void initStatusBar() {

    }

    @Override
    protected void initPresenter() {
        mPresenter = new NoSecretPayPresenter(this);
    }

    @Override
    protected void initView() {
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_no_secret_payment;
    }

    @Override
    public void retryRefreshData() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void showContent() {

    }

    @Override
    public void showProgress() {

    }

    @Override
    public void showError(Throwable throwable) {

    }

    @Override
    public void showEmpty() {

    }

    @Override
    public void showAgreeAliPay() {

        finish();
    }

    @OnClick({R.id.ivBack, R.id.tvPay})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ivBack:
                finish();
                break;
            case R.id.tvPay:
                if (validate()) {
                    mPresenter.agreeAliPayNoSecretPayment();
                }
                break;
        }
    }

    /**
     * 验证是否勾选授权协议
     *
     * @return
     */
    private boolean validate() {
        if (!cbAgree.isChecked()) {
            ToastUtil.makeShortToast("请同意授权协议");
            return false;
        }
        return true;
    }
}
